package com.njust.controller.SimpleUrlHandler;


import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 使用SimpleUrlHandlerMapping进行映射处理
 * 需要在spring配置文件中手动注册
 *
 *  <bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
 *       <property name="urlMap">
 *             <map>
 *                 <entry key="/simpleurl1.do" value="simpleUrlController1"/>
 *                 <entry key="/simpleurl2.do" value="simpleUrlController2"/>
 *             </map>
 *         </property>
 *
 *         <property name="mappings">
 *             <props>
 *                 <prop key="/simpleurl1.do">simpleUrlController1</prop>
 *                 <prop key="/simpleurl2.do">simpleUrlController2</prop>
 *             </props>
 *         </property>
 *     </bean>
 *
 */
@Controller
public class SimpleUrlController1 extends AbstractController {
    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {

        ModelAndView mv = new ModelAndView("success.jsp");
        mv.addObject("simpleurl", "这是SimpleUrlHandler映射器");
        return mv;
    }
}
